function typeText(element, htmlText, speed,func) {
    let id = element.id + "cur";
    element.innerHTML = `<span class="cursor" id="${id}"></span>`
    const cursorElement = document.getElementById(id);
    let currentIndex = 0;
    let currentHTML = "";
    let main = document.getElementById("main");
    function type() {
        if (currentIndex < htmlText.length) {
            const currentChar = htmlText.charAt(currentIndex);

            if (currentChar === "<") {
                const closingTagIndex = htmlText.indexOf(">", currentIndex);
                currentHTML += htmlText.slice(currentIndex, closingTagIndex + 1);
                currentIndex = closingTagIndex + 1;
            } else {
                currentHTML += currentChar;
                currentIndex++;
            }

            element.innerHTML = currentHTML;
            // 滚动到最底部
            main.scrollTop = main.scrollHeight;
            setTimeout(type, speed);
            
        } else {
            cursorElement.classList.remove("cursor");
            let h = element.offsetHeight;
            // 获取element的父元素
            let parent = element.parentElement;
            parent.style.height = h + "px";
            if (func) {
                func();
            }
        }
    }

    type();
}